﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SixApp.Extensions
{
    public static class DataGridViewExtentions
    {
        public static void DrawRowNumber(this DataGridView grid, DataGridViewRowPostPaintEventArgs args)
        {
            try
            {
                int y = (int)(args.RowBounds.Location.Y + (args.RowBounds.Height - grid.RowHeadersDefaultCellStyle.Font.Size) / 2);
                Rectangle rect = new Rectangle(args.RowBounds.Location.X, y, grid.RowHeadersWidth - 4, args.RowBounds.Height);

                TextRenderer.DrawText(args.Graphics, (args.RowIndex + 1).ToString(),
                                        grid.RowHeadersDefaultCellStyle.Font,
                                        rect,
                                        grid.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.Right);
            }
            catch (Exception ex)
            {

            }
        }
    }
}
